package com.puhui.lib.widgets

import android.content.Context
import android.util.AttributeSet
import androidx.core.widget.NestedScrollView

class CommonNestedScrollView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : NestedScrollView(context, attrs, defStyleAttr) {

    private var scrollViewListener: ScrollViewListener? = null

    fun setScrollListener(scrollViewListener: ScrollViewListener?) {
        this.scrollViewListener = scrollViewListener
    }

    override fun onScrollChanged(x: Int, y: Int, oldx: Int, oldy: Int) {
        super.onScrollChanged(x, y, oldx, oldy)
        scrollViewListener?.onScrollChanged(this, x, y, oldx, oldy)
    }

    interface ScrollViewListener {
        fun onScrollChanged(scrollView: CommonNestedScrollView, x: Int, y: Int, oldx: Int, oldy: Int)
    }
}